//
//  CFileUpload.h
//  OC_Test_1
//
//  Created by 四小鬼 on 16/9/12.
//  Copyright © 2016年 四小鬼. All rights reserved.
//

#import <Foundation/Foundation.h>

#pragma mark -
#pragma mark **********
#pragma mark  文件类
#pragma mark **********
#pragma mark -
@interface CFileModel : NSObject
// 上传文件 (可以是路径也可以是NSData类型数据)
@property (nonatomic, strong) id file;
// 上传名字
@property (nonatomic, strong) NSString *name;

#pragma mark - optional 可选属性
/**
 * @brief 设置关键Key值，读取时可以做区分
 * @see
 **/
@property (nonatomic, strong) NSString *key;

/**
 * @brief 状态
 * @see
 **/
@property (nonatomic) BOOL status;

/**
 * @brief 大小
 * @see
 **/
@property (nonatomic) float size;

/**
 * @brief 上传地址
 * @see
 **/
@property (nonatomic, strong) NSString *uploadpath;

#pragma mark - init Function
+ (CFileModel *) initWithFile:(id)file name:(NSString *)name;
@end


#pragma mark -
#pragma mark **********
#pragma mark  上传类
#pragma mark **********
#pragma mark -
@interface CFileUpload : NSObject
/**
 * @brief 获取CFileModel类
 * @param file 同 CFileModel类的file
 * @return CFileModel
 * @see
 **/
- (CFileModel *) getFileModelWith:(id) file;

/**
 * @brief 上传
 * @name
 * @param file 数组(CFileModel类数组)或CFileModel类
 * @param progress 进度block
 * @param finish 上传完成block
 * @see
 **/
- (void) uploadFiles:(id) file progress:(void (^)(CFileUpload *upload, float per))progress finish:(void(^)(CFileUpload *upload, NSArray *models, NSError *error)) finish;

/**
 * @brief 停止上传
 * @see
 **/
- (void) stopUpload;

/**
 * @brief 停止上传
 * @param file 同 CFileModel类的file
 * @see
 **/
- (void) stopUpload:(id) file;
@end

#pragma mark -
#pragma mark **********
#pragma mark  上传私有类
#pragma mark **********
#pragma mark -
@interface CFileUpload(CFileUploadPrivate)

/**
 * @brief 通过路径上传
 * @descript 不适合直接调用
 * @name
 * @param path 路径
 * @param progress 进度block
 * @param finish 上传完成block
 * @see
 **/
- (id) uploadFileByPath:(NSString *)path progress:(void (^)(CFileUpload *upload, float per))progress finish:(void(^)(CFileUpload *upload, NSArray *models, NSError *error)) finish;

/**
 * @brief 通过NSData上传
 * @descript 不适合直接调用
 * @name
 * @param data NSData
 * @param progress 进度block
 * @param finish 上传完成block
 * @see
 **/
- (id) uploadFileByData:(NSData *)data progress:(void (^)(CFileUpload *upload, float per))progress finish:(void(^)(CFileUpload *upload, NSArray *models, NSError *error)) finish;

@end
